/*
 * File:   ChessMove.h
 * Author: crash
 *
 * Created on February 26, 2011, 10:26 PM
 */

#ifndef CHESSMOVE_H
#define	CHESSMOVE_H

#include "IMove.h"
#include "ChessGame.h"
#include "Typesfwd.h"
#include <boost/regex.hpp>

class ChessMove : public IMove
{
public:
	ChessMove(const std::string& str);
	//    ChessMove(const ChessMove& orig);

	void execute(ChessGame&) const;
private:
	std::list<myTypes::movePtr> moves;
	static const boost::regex pattern;

	static const int PLACEPATTERN = 1, MOVEPATTERN = 6, INVALID = 12, PIECETYPE = PLACEPATTERN + 1, TEAM = PLACEPATTERN + 2, PLACECOL = PLACEPATTERN
			+ 3, PLACEROW = PLACEPATTERN + 4, MOVEFROMCOL = MOVEPATTERN + 1, MOVEFROMROW = MOVEPATTERN + 2, MOVETOCOL = MOVEPATTERN + 3,
			MOVETOROW =	MOVEPATTERN + 4, MOVECAPTURE = MOVETOROW + 1;

	static myTypes::cPiece charToPiece(char, bool);

	class PlacePiece : public IMove
	{
	public:
		PlacePiece(myTypes::cPiece p, const model::Location& loc);

		void execute(ChessGame&) const;
	private:
		const model::Location loc;
		const myTypes::cPiece piece;
	};

	class MovePiece : public IMove
	{
	public:
		MovePiece(const model::Location& from, const model::Location& to, bool capture);

		void execute(ChessGame&) const;
	private:
		const model::Location from, to;
		const bool capt;
	};

	class InvalidMove : public IMove
	{
	public:
		InvalidMove(const std::string& move);

		void execute(ChessGame&) const;
	private:
		const std::string move;
	};

};

#endif	/* CHESSMOVE_H */

